<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="/struts-tags" prefix="s"%>
<script type="text/javascript" charset="utf-8"
	src="js/jquery.listnav.min-2.1.js"></script>
<script type="text/javascript" charset="utf-8"
	src="js/jquery.dataTables.listnav.js"></script>
<script type="text/javascript" charset="utf-8">
	$(document)
			.ready(
					function() {
						$("input[name=expressionOfInterest]")
								.click(
										function() {
											if ($(
													"input[name=expressionOfInterest]")
													.prop("checked")) {
												$("ul#organisation-tab li#detail2")
														.after(
																"<li id='detail3'><a href='#2' data-toggle='tab'>Details 3</a></li>");
											} else {
												$("li#detail3").remove();
											}
										});
						if ($(
							"input[name=expressionOfInterest]")
							.prop("checked")) {
						$("ul#organisation-tab li#detail2")
								.after(
										"<li id='detail3'><a href='#2' data-toggle='tab'>Details 3</a></li>");
						} else {
							$("li#detail3").remove();
						}										

						$("a#mark-active-warning").click(function() {
							var organisationId = getURLParameter("organisationId");
							var r = confirm('This Organization is already in use, do you want to make this in-active?');
							if (r == true) {
								window.location.replace("markActiveOrganisation.action?organisationId=" + organisationId);
							}
						});
						
						var smTab = getURLParameterSupportingMaterial(document.location.href);						
						if (smTab == "4"){
							$("#0").removeClass("active");
							$("li#detail1").removeClass("active");							
							
							$("li#detail5").addClass("active");
							$("#4").addClass("active");
						}
						
						//validate postcode
						var postcodes = new Array();
						
						$.ajax({
							url: 'checkPostCodeAjax.action',
							success: function(data){
								postcodes = data.postcodes;
							}
						});
						
						$("form#update-organisation").submit(function() {
							if (jQuery.trim($("input#postcode-id").val()).length == 0) {
								alert("Postcode cannot be null!");
								return false;
							} else {
								var flag = $.inArray($("input#postcode-id").val(), postcodes);
								if (flag == -1) {
									var r = confirm('Address Details cannot be confirmed - Do you wish to enter Unconfirmed Address Data?');
									if (r == true) {
										return true;
									} else {
										$("input#postcode-id").val("");
										$("input#postcode-id").focus();
										return false;
									}
								} else {
									return true;
								}
								return false;	
							}							
						});
						
					});

	
	function getURLParameter(name) {
	    return decodeURI(
	        (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1]
	    );
	}

	function getURLParameterSupportingMaterial(url) {
		var n=url.indexOf("4");	
		if (n != -1) return "4";
		return false;
	}

</script>
<script type="text/javascript" charset="utf-8">

	$(document).ready(function() {
		var ok = getURLParameterOther(document.location.href);
		if (ok == true){
			$("#0").removeClass("active");
			$("#1").removeClass("active");
			$("#3").removeClass("active");
			$("#4").removeClass("active");
			$("#directorate").addClass("active");
			
			$("#detail1").removeClass("active");
			$("#directorates").addClass("active");
		}
			
	
	});
	
	function getURLParameterOther(url) {
		var n=url.indexOf("directorate");	
		if (n != -1) return true;
		return false;
	}
</script>	
<s:if test="#session.logged != 'true'">
	<jsp:forward page="../index.jsp" />
</s:if>
<div class="content">
	<div class="row-fluid">
		<form id="update-organisation" action="updateOrganisation.action?organisationId=<s:property value='organisationId' />" class='validate form-horizontal' method="post">
		<div class="span12">
			<div class="box">
				
				<!-- BreadCrumbs -->
					<div class="box-head "> 
						<jsp:include page="breadCrumbs.jsp" >
						<jsp:param value="0" name="bc"/>
						</jsp:include>
					</div>
				
					<!-- Box -->
			
				<div class="box-head tabs">
					<div style="width: 500px;">
						<h3>Organisation Details</h3>
						<ul id="organisation-tab" class="nav nav-tabs"
							style="float: left; margin-top: 10px;">
							<li id="detail1" class='active'><a href="#0" data-toggle="tab">Details
									1</a></li>
							<li id="detail2"><a href="#1" data-toggle="tab">Details 2</a></li>
							<!-- <li><a href="#2" data-toggle="tab">Details 3</a></li> -->
							<li id="detail4"><a href="#3" data-toggle="tab">Details 4</a></li>
							<li id="detail5"><a href="#4" data-toggle="tab">Details 5</a></li>
							<li id="directorates"><a href="#directorate" data-toggle="tab">BU/Directorates</a></li>
						</ul>
					</div>
					<div style="float: right;">
						<ul style="list-style: none; margin: 10px 0 0 0;">
							<li style="float: left; margin-right: 10px;">
								<s:if test="organisation.expressionOfInterest">																					
									<a id="mark-active-warning" href="#" class="btn btn-success">In-active</a>
								</s:if>
								<s:else>
									<a id="mark-active" href="markActiveOrganisation.action?organisationId=<s:property value='organisationId' />" class="btn btn-success">In-active</a>
								</s:else>
							</li>
							<li style="float: left; margin-right: 10px;"><button class="btn btn-success" type="submit">Save</button></li>
							<li style="float: left; margin-right: 10px;"><a id=""
								href="listOrganisation.action" class="btn btn-success">Back</a></li>
						</ul>
					</div>
				</div>
				<div class="box-content" id="organisation">
					<div class="tab-content">
						<div class="tab-pane active" id="0">
							<div class="row-fluid force-margin">
								<div class="span3">
									<div class="control-group">
										<label for="req" class="control-label require">Organisation
											Name</label>
										<div class="controls">
											<input type="text" name="organisationName" id="req"
												class='required'
												value='<s:property value='organisation.organisationName' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label require">Organisation
											Short Description</label>
										<div class="controls">
											<textarea style="resize: none; width: 219px;"
												name="organisationShortDescription" id="basictext"
												class='span9 input-square' rows="6"><s:property value='organisation.organisationShortDescription' />
												</textarea>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Lead Contact</label>
										<div class="controls">
											<input type="hidden" name="leadContactId" id="contact-id"
												class='input-medium input-square' readonly="readonly"
												value='<s:property value='organisation.leadContact.id' />'> <input
												type="text" name="leadContactName" id="contact-name"
												class='input-medium input-square' readonly="readonly"
												value='<s:property value='organisation.leadContact.firstname' /> <s:property value='organisation.leadContact.surname' />'>
											<a class="" id="lookup-contact" data-toggle="modal" href="#lookUpContact">Lookup</a>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label require">Address Line 1</label>
										<div class="controls">
											<input type="text" name="addressLine1" id="req"
												value='<s:property value='organisation.addressLine1' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Address Line 2</label>
										<div class="controls">
											<input type="text" name="addressLine2" id="req"
												value='<s:property value='organisation.addressLine2' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Address Line 3</label>
										<div class="controls">
											<input type="text" name="addressLine3" id="req"
												value='<s:property value='organisation.addressLine3' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="email3" class="control-label require">Postcode</label>
										<div class="controls">
											<input type="text" name="postcode" id="postcode-id"
												class='input-medium input-square'
												value='<s:property value='organisation.postcode' />'>
											<a class="" id="lookup-postcode" data-toggle="modal" href="#lookUpPostcode">Lookup</a>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">City/Town</label>
										<div class="controls">
											<input type="text" name="city" id="req"
												value='<s:property value='organisation.city' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">County</label>
										<div class="controls">
											<input type="text" name="county" id="req"
												value='<s:property value='organisation.county' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Nation/Country</label>
										<div class="controls">
											<s:select list="countries" name="country"
												listKey="countryId" listValue="countryName" id="selsear"
												headerKey="-1" required="true"
												value="#{organisation.country.countryId}" headerValue="">
											</s:select>
										</div>
									</div>
								</div>
								<div class="span3">
									<div class="control-group">
										<label for="medium" class="control-label">Preferred
											Organisation</label>
										<div class="controls">
											<s:if test="organisation.preferredOrganisation">												
												<s:checkbox name="preferredOrganisation" checked="checked" />
											</s:if>
											<s:else>												
												<s:checkbox name="preferredOrganisation" />
											</s:else>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Expression of
											Interest</label>
										<div class="controls">
											<s:if test="organisation.expressionOfInterest">												
												<s:checkbox name="expressionOfInterest" checked="checked" />
											</s:if>
											<s:else>
												<s:checkbox name="expressionOfInterest" />
											</s:else>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label require">Type of
											Business</label>
										<div class="controls">
											<input type="hidden" name="businessId" id="businessIdHidden"
												class='input-medium input-square' readonly="readonly"
												value='<s:property value='organisation.businessType.businessId' />'>
											<input type="text" name="businessName" id="txtBussinessName"
												class='input-medium input-square' readonly="readonly"
												value='<s:property value='organisation.businessType.businessName' />'>
											<a id="look-up" data-toggle="modal" href="#lookUpBusiness">Lookup</a>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">SIC Code</label>
										<div class="controls">
											<input style="width: 50px;" type="text" name="sICCodeField"
												id="txtSICCode" class='input-medium input-square' 
												readonly="readonly" value='<s:property value='organisation.businessType.sICCode' />'>

										</div>
									</div>
									<div class="control-group">
										<label for="check" class="control-label">Organisation
											Full Description</label>
										<div class="controls">
											<textarea style="resize: none; width: 219px;"
												name="organisationFullDescription" id="basictext"
												class='span9 input-square' rows="6"><s:property value='organisation.organisationFullDescription' />
												</textarea>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label require">Phone Number</label>
										<div class="controls">
											<input type="text" name="phoneNumber" id="req"
												class='required'
												value='<s:property value='organisation.phoneNumber' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Fax</label>
										<div class="controls">
											<input type="text" name="fax" id="req" class='required'
												value='<s:property value='organisation.fax' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Email</label>
										<div class="controls">
											<input type="text" name="email" id="req" class='required'
												value='<s:property value='organisation.email' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Web Address</label>
										<div class="controls">
											<input type="text" name="webAddress" id="req"
												class='required'
												value='<s:property value='organisation.webAddress' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Charity Number</label>
										<div class="controls">
											<input type="text" name="charityNumber" id="req"
												class='required'
												value='<s:property value='organisation.charityNumber' />'>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Company Number</label>
										<div class="controls">
											<input type="text" name="companyNumber" id="req"
												class='required'
												value='<s:property value='organisation.companyNumber' />'>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="tab-pane" id="1">
							<div class="row-fluid force-margin">
								<div class="span3">
									<div class="control-group">
										<label for="req" class="control-label">Organisation
											Specialism</label>
										<div class="controls">
											<div class="div-menu">
												<div class="control-group" style="margin-left: 10px;">
													<div class="controls">
														<s:checkboxlist theme="vertical-checkbox" list="organisationSpecialisms" name="organisationSpecialism" listKey="id" listValue="name" value="organisationSpecialisms1"></s:checkboxlist>
														<%-- <s:iterator value="organisationSpecialisms"
															var="organisationSpecialism">
															<label class="checkbox"><input type="checkbox"
																class='uniform' name="check" id="check2"															
																value="<s:property value="id" />" 
																<s:iterator value="organisationSpecialisms1"
																var="organisationSpecialism1">
																	<s:if test="%{#organisationSpecialism.id==#organisationSpecialism1.id}">
																		checked="checked"															
																	</s:if>
																</s:iterator>> 
																<s:property value="name" /></label>																	
														</s:iterator>		 --%>												
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Service
											Disabilities Capabilities</label>
										<div class="controls">
											<div class="div-menu">
												<div class="control-group" style="margin-left: 10px;">
													<div class="controls">	
														<s:checkboxlist theme="vertical-checkbox" list="disabilitiesCapabilities" name="disabilitiesCapability" listKey="id" listValue="name" value="disabilitiesCapabilities1"></s:checkboxlist>																																																																																																						
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Service
											Barriers Capabilities</label>
										<div class="controls">
											<div class="div-menu">
												<div class="control-group" style="margin-left: 10px;">
													<div class="controls">													
														<s:checkboxlist theme="vertical-checkbox" list="barriersCapabilities" name="barriersCapability" listKey="id" listValue="name" value="barriersCapabilities1"></s:checkboxlist>
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Service
											Benefits Capabilities</label>
										<div class="controls">
											<div class="div-menu">
												<div class="control-group" style="margin-left: 10px;">
													<div class="controls">
														<s:checkboxlist theme="vertical-checkbox" list="benefitsCapabilities" name="benefitsCapability" listKey="id" listValue="name" value="benefitsCapabilities1"></s:checkboxlist>	
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
								<div class="span3">
									<div class="control-group">
										<label for="req" class="control-label">Service
											Personal Circumstances Capabilities</label>
										<div class="controls">
											<div class="div-menu">
												<div class="control-group" style="margin-left: 10px;">
													<div class="controls">														
														<s:checkboxlist theme="vertical-checkbox" list="servicePersonalCircumstancesCapabilities" name="servicePersonalCircumstancesCapability" listKey="id" listValue="name" value="servicePersonalCircumstancesCapabilities1"></s:checkboxlist>	
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Service
											Ethnicity Capabilities</label>
										<div class="controls">
											<div class="div-menu">
												<div class="control-group" style="margin-left: 10px;">
													<div class="controls">														
														<s:checkboxlist theme="vertical-checkbox" list="ethnicityCapabilities" name="ethnicityCapability" listKey="id" listValue="name" value="ethnicityCapabilities1"></s:checkboxlist>	
													</div>
												</div>
											</div>
										</div>
									</div>
									<div class="control-group">
										<label for="req" class="control-label">Accreditation</label>
										<div class="controls">
											<div class="div-menu">
												<div class="control-group" style="margin-left: 10px;">
													<div class="controls">														
														<s:checkboxlist theme="vertical-checkbox" list="accreditations" name="accreditation" listKey="id" listValue="name" value="accreditations1"></s:checkboxlist>	
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
						<div class="tab-pane" id="2">
							<div class="row-fluid force-margin">
								<div class="span3">
									<div class="control-group">
										<label for="req" class="control-label">EOI Programmes</label>
										<div class="controls">
											<div class="div-menu">
												<div class="control-group" style="margin-left: 10px;">
													<div class="controls">														
														<s:checkboxlist theme="vertical-checkbox" list="programmes" name="programme" listKey="id" listValue="name" value="programmes1"></s:checkboxlist>	
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
								<div class="span3">
									<div class="control-group">
										<label for="req" class="control-label">EOI Services</label>
										<div class="controls">
											<div class="div-menu">
												<div class="control-group" style="margin-left: 10px;">
													<div class="controls">													
														<s:checkboxlist theme="vertical-checkbox" list="services" name="service" listKey="id" listValue="name" value="services1"></s:checkboxlist>	
													</div>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>	
						<%@ include file="details4.jsp"%>
						<%@ include file="listSupportingMaterial.jsp"%>						
						<%@ include file="listDirectorates.jsp"%>
					</div>
				</div>
			</div>
		</div>
		</form>
	</div>
</div>
<!-- Lookup -->
<!-- BusinessType -->
<div id="pageLookupBusinessType"> 
	<%@ include file="LookupBusinessType.jsp" %>
</div>
<!-- Contact -->
<div id="pageLookUpContact">
	<%@ include file="lookUpContact.jsp"%>
</div>
<!-- Postcode -->
<div id="pageLookupPostcode">
	<%@ include file="lookUpPostcode.jsp" %>
</div>